const preventReClick = Vue.directive('preventReClick', {
  inserted: function (el, binding, vNode, oldVnode) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true
        el.style.backgroundColor = '#ccc'
        el.style.border = 'none'
        setTimeout(() => {
          el.disabled = false
          el.style.backgroundColor = '#1890ff'
          el.style.border = '1px solid #1890ff'
        }, 500)
      }
    })
  }
})

export default preventReClick
